<template>
  <div class="app-container">
    <div style="height: 10px"></div>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column
        align="center"
        prop="id"
        label="任务id"
        min-width="100"
      />
      <el-table-column
        align="center"
        prop="title"
        label="标题"
        min-width="100"
      />
      <el-table-column
        align="center"
        prop="createrUsername"
        label="发布人"
        min-width="100"
      />
      <el-table-column
        align="center"
        prop="content"
        label="描述"
        min-width="100"
      />
      <el-table-column align="center" label="状态" width="150">
        <template slot-scope="scope">
          <el-tag
            v-if="scope.row.feekbackStatus * 1 === 1"
            type="success"
            size="small"
            >已反馈</el-tag
          >
          <el-tag v-else type="danger" size="small">未反馈</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="startTime"
        label="指派时间"
        min-width="100"
      />
      <el-table-column
        align="center"
        prop="feekbackTime"
        label="反馈时间"
        min-width="100"
      />
      <el-table-column
        align="center"
        fixed="right"
        label="操作"
        width="250"
        class-name="small-padding"
      >
        <template slot-scope="scope">
          <el-button type="text" size="mini" @click="clickfankuixx(scope.row)">
            详情</el-button
          >
          <el-button
            type="text"
            size="mini"
            :disabled="scope.row.feekbackStatus * 1 === 1"
            @click="clickfankui(scope.row)"
          >
            反馈</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="listQuery.pageNo"
      :limit.sync="listQuery.pageSize"
      @pagination="getdata"
    />

    <!-- 创建任务弹窗 -->
    <el-dialog title="反馈任务" :visible.sync="dialogFormVisible" width="80%">
      <taskinfo
        :clickinfo="clickinfo"
        :isfankui="true"
        @clicksure="fanhuisuccess"
        @clickcancle="dialogFormVisible = false"
      ></taskinfo>
    </el-dialog>
    <!-- 任务详情 -->
    <el-dialog title="任务详情" :visible.sync="dialogForminfo" width="80%">
      <taskinfo
        :clickinfo="clickinfo"
        @clicksure="dialogForminfo = false"
      ></taskinfo>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";

import { userlist } from "@/api/user";
import { taskfeekbacksave, list, tasknotfeekbacklist } from "@/api/task";
import Pagination from "@/components/Pagination"; // Secondary package based on el-pagination
import dayjs from "dayjs";
import taskinfo from "@/views/component/taskinfo"; // Secondary package based on el-pagination

const defavalue = {
  title: "",
  context: "",
  filename: "",
  fileurl: "",
};
export default {
  components: { Pagination, taskinfo },
  computed: {
    ...mapGetters(["uid", "updatepath", "token"]),
  },
  filters: {},
  data() {
    return {
      headers: {},
      clickinfo: {},
      fankinfo: {},
      dialogForminfo: false,
      userlist: [],
      listQuery: {
        pageNo: 1,
        pageSize: 20,
      },
      listLoading: false,
      total: 0,
      list: [],
      form: {
        id: "",
        title: "",
        context: "",
        filename: "",
        fileurl: "",
        selectuser: null,
      },
      updateing: false,
      dialogFormVisible: false,
    };
  },

  created() {
    this.headers = {
      token: this.token,
    };
    this.getuserlist();
    this.getdata();
  },
  methods: {
    
    getdata() {
      this.listLoading = true;
      let data = { ...this.listQuery, userId: this.uid };
      list(data).then((res) => {
        this.list = res.data.records;
        this.total = res.data.total;
        this.listLoading = false;
        console.log(this.list);
      });
    },
    // 获取用户列表
    getuserlist() {
      userlist({
        pageSize: 9999,
        pageNo: 1,
      }).then((res) => {
        this.userlist = res.data.records;
      });
    },

    clickfankui(e) {
      console.log(e);
      this.clickinfo = _.cloneDeep(e);

      this.dialogFormVisible = true;
    },
    // 反馈详情
    clickfankuixx(item) {
      this.clickinfo = _.cloneDeep(item);
      this.dialogForminfo = true;
    },
    // 反馈成功
    fanhuisuccess(){
      this.dialogFormVisible = false;
      this.getdata();
    }
  },
};
</script>


<style lang="scss" scoped>
.filter-item {
  margin-left: 4px;
  margin-right: 20px;
}
.avaimg {
  width: 50px;
  height: 50px;
}
.bs-sysMsg {
  position: relative;
  display: flex;
  width: 80%;
  padding: 5px 5px;
  // border-radius: 2px;
  color: #017dff;
  background-color: #fff;
  overflow: hidden;
  opacity: 1;
  align-items: center;
  transition: opacity 0.2s;
}
.bs-sysMsg .msg__content {
  display: table-cell;
  padding: 0 8px;
  width: 100%;
}
.bs-sysMsg .msg__content a.item {
  color: red;
  font-size: 15px;
  opacity: 0.75;
}
.bs-sysMsg .msg__content a.item:hover {
  text-decoration: underline;
}
</style>
